package com.zlx.xbhy.service.impl;


import com.zlx.xbhy.entity.UserFocus;
import com.zlx.xbhy.mapper.UserFocusMapper;
import com.zlx.xbhy.service.UserFocusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author 周罗校
 * @Description
 * @ClassName UserFocusServiceImpl
 * @date 2020.11.18 10:38:38
 * 该版权归周罗校所有，最终解释权以官方为准
 */
@Service
@Transactional
public class UserFocusServiceImpl extends BaseServiceImpl<UserFocus,Long> implements UserFocusService {
    @Autowired
    private UserFocusMapper mapper;
    /***
     * @Author 周罗校
     * @Description  关注用户
     * @Param [focus]
     * @return void
     * @Date 2020.11.18 13:46:17
     **/
    @Override
    public void focusUser(UserFocus focus) {
        UserFocus userFocus = mapper.selectOne(focus);
        if (userFocus==null){//说明用户未关注该用户
            mapper.insert(focus);
        }
    }

    @Override
    public void cancelFocusUser(UserFocus focus) {
        //取消关注用户
        UserFocus userFocus = mapper.selectOne(focus);
        if (userFocus!=null){//说明用户已经关注该用户
            mapper.delete(focus);
        }
    }
}
